package ejercicioEncriptador;

public class NextVocalStrategy extends EncriptStrategy {

	@Override
	public String encriptar(String palabraOriginal) {
		String palabraVocalesCambiadas = "";

		System.out.println(palabraOriginal);
		
		for (int i = 0; i < palabraOriginal.length(); i++) {

			palabraVocalesCambiadas = palabraVocalesCambiadas.concat(this.nextVocals(palabraOriginal.charAt(i)));
		}
		System.out.println(palabraVocalesCambiadas);
		
		String result = new StringBuffer(palabraVocalesCambiadas).reverse().toString();
		System.out.println(result);
		return result;
		
	}

	public String nextVocals(char charAt) {

		if (this.isVocal(charAt)) {

			return this.covertToNext(charAt);
		}

		return String.valueOf(charAt);
	}

	public String covertToNext(char charAt) {
		
		if(charAt == 'a'){
			
			return "e";
		}
		if(charAt == 'e'){
			
			return "i";
		}
		if(charAt == 'i'){
			
			return "o";
		}
		if(charAt == 'o'){
			
			return "u";
		}
		if(charAt == 'u'){
			
			return "a";
		}
	
		return null;
	}

	public boolean isVocal(char charAt) {
		int ascciOfWord = (int) charAt;

		if (ascciOfWord == 97 || ascciOfWord == 101 || ascciOfWord == 105
				|| ascciOfWord == 111 || ascciOfWord == 117) {

			return true;
		}

		return false;
	}

	
	
}
